import request from '@/config/axios'

export const TaskApi = {
  getTaskListByProcessInstanceId: async (processInstanceId: string) => {
    return await request.get({
      url: '/bpm/task/list-by-process-instance-id',
      params: { processInstanceId }
    })
  },

  getTaskManagePage: async (params: PageParam) => {
    return await request.get({ url: '/bpm/task/manage-page', params })
  },

  getTaskTodoPage: async (params: PageParam) => {
    return await request.get({ url: '/bpm/task/todo-page', params })
  },

  getTaskDonePage: async (params: PageParam) => {
    return await request.get({ url: '/bpm/task/done-page', params })
  },

  // 领取任务
  claimTask: async (id: string) => {
    return await request.post({ url: '/bpm/task/claim', params: { id } })
  },

  // 取消领取任务
  unclaimTask: async (id: string) => {
    return await request.post({ url: '/bpm/task/unclaim', params: { id } })
  },

  // 审批通过
  approveTask: async (data: any) => {
    return await request.post({ url: '/bpm/task/approve', data })
  },

  // 审批拒绝
  rejectTask: async (data: any) => {
    return await request.post({ url: '/bpm/task/reject', data })
  },

  // 委派
  delegateTask: async (data: any) => {
    return await request.post({ url: '/bpm/task/delegate', data })
  },

  // 转派
  transferTask: async (data: any) => {
    return await request.post({ url: '/bpm/task/transfer', data })
  },

  // 加签
  signCreateTask: async (data: any) => {
    return await request.post({ url: '/bpm/task/create-sign', data })
  },

  // 减签
  signDeleteTask: async (data: any) => {
    return await request.delete({ url: '/bpm/task/delete-sign', data })
  },

  // 获取可回退任务列表
  getTaskListByReturn: async (id: string) => {
    return await request.get({ url: '/bpm/task/list-by-return', params: { id } })
  },

  // 回退
  returnTask: async (data: any) => {
    return await request.post({ url: '/bpm/task/return', data })
  },

  // 抄送
  copyTask: async (data: any) => {
    return await request.post({ url: '/bpm/task/copy', data })
  }
}
